home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / info / lispref.info-17.z / lispref.info-17
Encoding:
GNU Info File  |  1998-05-21  |  49.6 KB  |  1,145 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo version
  2. 1.68 from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995 XEmacs Lisp
  12. Reference Manual (for 19.14 and 20.0) v3.1, March 1996 XEmacs Lisp
  13. Reference Manual (for 19.15 and 20.1, 20.2) v3.2, April, May 1997
  14.  
  15.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  16. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  17. Copyright (C) 1995, 1996 Ben Wing.
  18.  
  19.    Permission is granted to make and distribute verbatim copies of this
  20. manual provided the copyright notice and this permission notice are
  21. preserved on all copies.
  22.  
  23.    Permission is granted to copy and distribute modified versions of
  24. this manual under the conditions for verbatim copying, provided that the
  25. entire resulting derived work is distributed under the terms of a
  26. permission notice identical to this one.
  27.  
  28.    Permission is granted to copy and distribute translations of this
  29. manual into another language, under the above conditions for modified
  30. versions, except that this permission notice may be stated in a
  31. translation approved by the Foundation.
  32.  
  33.    Permission is granted to copy and distribute modified versions of
  34. this manual under the conditions for verbatim copying, provided also
  35. that the section entitled "GNU General Public License" is included
  36. exactly as in the original, and provided that the entire resulting
  37. derived work is distributed under the terms of a permission notice
  38. identical to this one.
  39.  
  40.    Permission is granted to copy and distribute translations of this
  41. manual into another language, under the above conditions for modified
  42. versions, except that the section entitled "GNU General Public License"
  43. may be included in a translation approved by the Free Software
  44. Foundation instead of in the original English.
  45.  
  46. 
  47. File: lispref.info,  Node: Reading One Event,  Next: Dispatching an Event,  Prev: Key Sequence Input,  Up: Reading Input
  48.  
  49. Reading One Event
  50. -----------------
  51.  
  52.    The lowest level functions for command input are those which read a
  53. single event.  These functions often make a distinction between
  54. "command events", which are user actions (keystrokes and mouse
  55. actions), and other events, which serve as communication between XEmacs
  56. and the window system.
  57.  
  58.  - Function: next-event &optional EVENT PROMPT
  59.      This function reads and returns the next available event from the
  60.      window system or terminal driver, waiting if necessary until an
  61.      event is available.  Pass this object to `dispatch-event' to
  62.      handle it. If an event object is supplied, it is filled in and
  63.      returned; otherwise a new event object will be created.
  64.  
  65.      Events can come directly from the user, from a keyboard macro, or
  66.      from `unread-command-events'.
  67.  
  68.      In most cases, the function `next-command-event' is more
  69.      appropriate.
  70.  
  71.  - Function: next-command-event &optional EVENT
  72.      This function returns the next available "user" event from the
  73.      window system or terminal driver.  Pass this object to
  74.      `dispatch-event' to handle it.  If an event object is supplied, it
  75.      is filled in and returned, otherwise a new event object will be
  76.      created.
  77.  
  78.      The event returned will be a keyboard, mouse press, or mouse
  79.      release event.  If there are non-command events available (mouse
  80.      motion, sub-process output, etc) then these will be executed (with
  81.      `dispatch-event') and discarded.  This function is provided as a
  82.      convenience; it is equivalent to the Lisp code
  83.  
  84.               (while (progn
  85.                    (next-event event)
  86.                        (not (or (key-press-event-p event)
  87.                                 (button-press-event-p event)
  88.                                 (button-release-event-p event)
  89.                                 (menu-event-p event))))
  90.                  (dispatch-event event))
  91.  
  92.      Here is what happens if you call `next-command-event' and then
  93.      press the right-arrow function key:
  94.  
  95.           (next-command-event)
  96.                => #<keypress-event right>
  97.  
  98.  - Function: read-char
  99.      This function reads and returns a character of command input.  If a
  100.      mouse click is detected, an error is signalled.  The character
  101.      typed is returned as an ASCII value.  This function is retained for
  102.      compatibility with Emacs 18, and is most likely the wrong thing
  103.      for you to be using: consider using `next-command-event' instead.
  104.  
  105.  - Function: enqueue-eval-event FUNCTION OBJECT
  106.      This function adds an eval event to the back of the queue.  The
  107.      eval event will be the next event read after all pending events.
  108.  
  109. 
  110. File: lispref.info,  Node: Dispatching an Event,  Next: Quoted Character Input,  Prev: Reading One Event,  Up: Reading Input
  111.  
  112. Dispatching an Event
  113. --------------------
  114.  
  115.  - Function: dispatch-event EVENT
  116.      Given an event object returned by `next-event', this function
  117.      executes it.  This is the basic function that makes XEmacs respond
  118.      to user input; it also deals with notifications from the window
  119.      system (such as Expose events).
  120.  
  121. 
  122. File: lispref.info,  Node: Quoted Character Input,  Next: Peeking and Discarding,  Prev: Dispatching an Event,  Up: Reading Input
  123.  
  124. Quoted Character Input
  125. ----------------------
  126.  
  127.    You can use the function `read-quoted-char' to ask the user to
  128. specify a character, and allow the user to specify a control or meta
  129. character conveniently, either literally or as an octal character code.
  130. The command `quoted-insert' uses this function.
  131.  
  132.  - Function: read-quoted-char &optional PROMPT
  133.      This function is like `read-char', except that if the first
  134.      character read is an octal digit (0-7), it reads up to two more
  135.      octal digits (but stopping if a non-octal digit is found) and
  136.      returns the character represented by those digits in octal.
  137.  
  138.      Quitting is suppressed when the first character is read, so that
  139.      the user can enter a `C-g'.  *Note Quitting::.
  140.  
  141.      If PROMPT is supplied, it specifies a string for prompting the
  142.      user.  The prompt string is always displayed in the echo area,
  143.      followed by a single `-'.
  144.  
  145.      In the following example, the user types in the octal number 177
  146.      (which is 127 in decimal).
  147.  
  148.           (read-quoted-char "What character")
  149.           
  150.           ---------- Echo Area ----------
  151.           What character-177
  152.           ---------- Echo Area ----------
  153.           
  154.                => 127
  155.  
  156. 
  157. File: lispref.info,  Node: Peeking and Discarding,  Prev: Quoted Character Input,  Up: Reading Input
  158.  
  159. Miscellaneous Event Input Features
  160. ----------------------------------
  161.  
  162.    This section describes how to "peek ahead" at events without using
  163. them up, how to check for pending input, and how to discard pending
  164. input.
  165.  
  166.    See also the variables `last-command-event' and `last-command-char'
  167. (*Note Command Loop Info::).
  168.  
  169.  - Variable: unread-command-events
  170.      This variable holds a list of events waiting to be read as command
  171.      input.  The events are used in the order they appear in the list,
  172.      and removed one by one as they are used.
  173.  
  174.      The variable is needed because in some cases a function reads a
  175.      event and then decides not to use it.  Storing the event in this
  176.      variable causes it to be processed normally, by the command loop
  177.      or by the functions to read command input.
  178.  
  179.      For example, the function that implements numeric prefix arguments
  180.      reads any number of digits.  When it finds a non-digit event, it
  181.      must unread the event so that it can be read normally by the
  182.      command loop.  Likewise, incremental search uses this feature to
  183.      unread events with no special meaning in a search, because these
  184.      events should exit the search and then execute normally.
  185.  
  186.  
  187.  - Variable: unread-command-event
  188.      This variable holds a single event to be read as command input.
  189.  
  190.      This variable is mostly obsolete now that you can use
  191.      `unread-command-events' instead; it exists only to support programs
  192.      written for versions of XEmacs prior to 19.12.
  193.  
  194.  - Function: input-pending-p
  195.      This function determines whether any command input is currently
  196.      available to be read.  It returns immediately, with value `t' if
  197.      there is available input, `nil' otherwise.  On rare occasions it
  198.      may return `t' when no input is available.
  199.  
  200.  - Variable: last-input-event
  201.      This variable is set to the last keyboard or mouse button event
  202.      received.
  203.  
  204.      This variable is off limits: you may not set its value or modify
  205.      the event that is its value, as it is destructively modified by
  206.      `read-key-sequence'.  If you want to keep a pointer to this value,
  207.      you must use `copy-event'.
  208.  
  209.      Note that this variable is an alias for `last-input-char' in FSF
  210.      Emacs.
  211.  
  212.      In the example below, a character is read (the character `1').  It
  213.      becomes the value of `last-input-event', while `C-e' (from the
  214.      `C-x C-e' command used to evaluate this expression) remains the
  215.      value of `last-command-event'.
  216.  
  217.           (progn (print (next-command-event))
  218.                  (print last-command-event)
  219.                  last-input-event)
  220.                -| #<keypress-event 1>
  221.                -| #<keypress-event control-E>
  222.                => #<keypress-event 1>
  223.  
  224.  - Variable: last-input-char
  225.      If the value of `last-input-event' is a keyboard event, then this
  226.      is the nearest ASCII equivalent to it.  Remember that there is
  227.      *not* a 1:1 mapping between keyboard events and ASCII characters:
  228.      the set of keyboard events is much larger, so writing code that
  229.      examines this variable to determine what key has been typed is bad
  230.      practice, unless you are certain that it will be one of a small
  231.      set of characters.
  232.  
  233.      This function exists for compatibility with Emacs version 18.
  234.  
  235.  - Function: discard-input
  236.      This function discards the contents of the terminal input buffer
  237.      and cancels any keyboard macro that might be in the process of
  238.      definition.  It returns `nil'.
  239.  
  240.      In the following example, the user may type a number of characters
  241.      right after starting the evaluation of the form.  After the
  242.      `sleep-for' finishes sleeping, `discard-input' discards any
  243.      characters typed during the sleep.
  244.  
  245.           (progn (sleep-for 2)
  246.                  (discard-input))
  247.                => nil
  248.  
  249. 
  250. File: lispref.info,  Node: Waiting,  Next: Quitting,  Prev: Reading Input,  Up: Command Loop
  251.  
  252. Waiting for Elapsed Time or Input
  253. =================================
  254.  
  255.    The wait functions are designed to wait for a certain amount of time
  256. to pass or until there is input.  For example, you may wish to pause in
  257. the middle of a computation to allow the user time to view the display.
  258. `sit-for' pauses and updates the screen, and returns immediately if
  259. input comes in, while `sleep-for' pauses without updating the screen.
  260.  
  261.    Note that in FSF Emacs, the commands `sit-for' and `sleep-for' take
  262. two arguments to specify the time (one integer and one float value),
  263. instead of a single argument that can be either an integer or a float.
  264.  
  265.  - Function: sit-for SECONDS &optional NODISP
  266.      This function performs redisplay (provided there is no pending
  267.      input from the user), then waits SECONDS seconds, or until input is
  268.      available.  The result is `t' if `sit-for' waited the full time
  269.      with no input arriving (see `input-pending-p' in *Note Peeking and
  270.      Discarding::).  Otherwise, the value is `nil'.
  271.  
  272.      The argument SECONDS need not be an integer.  If it is a floating
  273.      point number, `sit-for' waits for a fractional number of seconds.
  274.  
  275.      Redisplay is normally preempted if input arrives, and does not
  276.      happen at all if input is available before it starts. (You can
  277.      force screen updating in such a case by using `force-redisplay'.
  278.      *Note Refresh Screen::.) If there is no input pending, you can
  279.      force an update with no delay by using `(sit-for 0)'.
  280.  
  281.      If NODISP is non-`nil', then `sit-for' does not redisplay, but it
  282.      still returns as soon as input is available (or when the timeout
  283.      elapses).
  284.  
  285.      The usual purpose of `sit-for' is to give the user time to read
  286.      text that you display.
  287.  
  288.  - Function: sleep-for SECONDS
  289.      This function simply pauses for SECONDS seconds without updating
  290.      the display.  This function pays no attention to available input.
  291.      It returns `nil'.
  292.  
  293.      The argument SECONDS need not be an integer.  If it is a floating
  294.      point number, `sleep-for' waits for a fractional number of seconds.
  295.  
  296.      Use `sleep-for' when you wish to guarantee a delay.
  297.  
  298.    *Note Time of Day::, for functions to get the current time.
  299.  
  300. 
  301. File: lispref.info,  Node: Quitting,  Next: Prefix Command Arguments,  Prev: Waiting,  Up: Command Loop
  302.  
  303. Quitting
  304. ========
  305.  
  306.    Typing `C-g' while a Lisp function is running causes XEmacs to
  307. "quit" whatever it is doing.  This means that control returns to the
  308. innermost active command loop.
  309.  
  310.    Typing `C-g' while the command loop is waiting for keyboard input
  311. does not cause a quit; it acts as an ordinary input character.  In the
  312. simplest case, you cannot tell the difference, because `C-g' normally
  313. runs the command `keyboard-quit', whose effect is to quit.  However,
  314. when `C-g' follows a prefix key, the result is an undefined key.  The
  315. effect is to cancel the prefix key as well as any prefix argument.
  316.  
  317.    In the minibuffer, `C-g' has a different definition: it aborts out
  318. of the minibuffer.  This means, in effect, that it exits the minibuffer
  319. and then quits.  (Simply quitting would return to the command loop
  320. *within* the minibuffer.)  The reason why `C-g' does not quit directly
  321. when the command reader is reading input is so that its meaning can be
  322. redefined in the minibuffer in this way.  `C-g' following a prefix key
  323. is not redefined in the minibuffer, and it has its normal effect of
  324. canceling the prefix key and prefix argument.  This too would not be
  325. possible if `C-g' always quit directly.
  326.  
  327.    When `C-g' does directly quit, it does so by setting the variable
  328. `quit-flag' to `t'.  XEmacs checks this variable at appropriate times
  329. and quits if it is not `nil'.  Setting `quit-flag' non-`nil' in any way
  330. thus causes a quit.
  331.  
  332.    At the level of C code, quitting cannot happen just anywhere; only
  333. at the special places that check `quit-flag'.  The reason for this is
  334. that quitting at other places might leave an inconsistency in XEmacs's
  335. internal state.  Because quitting is delayed until a safe place,
  336. quitting cannot make XEmacs crash.
  337.  
  338.    Certain functions such as `read-key-sequence' or `read-quoted-char'
  339. prevent quitting entirely even though they wait for input.  Instead of
  340. quitting, `C-g' serves as the requested input.  In the case of
  341. `read-key-sequence', this serves to bring about the special behavior of
  342. `C-g' in the command loop.  In the case of `read-quoted-char', this is
  343. so that `C-q' can be used to quote a `C-g'.
  344.  
  345.    You can prevent quitting for a portion of a Lisp function by binding
  346. the variable `inhibit-quit' to a non-`nil' value.  Then, although `C-g'
  347. still sets `quit-flag' to `t' as usual, the usual result of this--a
  348. quit--is prevented.  Eventually, `inhibit-quit' will become `nil'
  349. again, such as when its binding is unwound at the end of a `let' form.
  350. At that time, if `quit-flag' is still non-`nil', the requested quit
  351. happens immediately.  This behavior is ideal when you wish to make sure
  352. that quitting does not happen within a "critical section" of the
  353. program.
  354.  
  355.    In some functions (such as `read-quoted-char'), `C-g' is handled in
  356. a special way that does not involve quitting.  This is done by reading
  357. the input with `inhibit-quit' bound to `t', and setting `quit-flag' to
  358. `nil' before `inhibit-quit' becomes `nil' again.  This excerpt from the
  359. definition of `read-quoted-char' shows how this is done; it also shows
  360. that normal quitting is permitted after the first character of input.
  361.  
  362.      (defun read-quoted-char (&optional prompt)
  363.        "...DOCUMENTATION..."
  364.        (let ((count 0) (code 0) char)
  365.          (while (< count 3)
  366.            (let ((inhibit-quit (zerop count))
  367.                  (help-form nil))
  368.              (and prompt (message "%s-" prompt))
  369.              (setq char (read-char))
  370.              (if inhibit-quit (setq quit-flag nil)))
  371.            ...)
  372.          (logand 255 code)))
  373.  
  374.  - Variable: quit-flag
  375.      If this variable is non-`nil', then XEmacs quits immediately,
  376.      unless `inhibit-quit' is non-`nil'.  Typing `C-g' ordinarily sets
  377.      `quit-flag' non-`nil', regardless of `inhibit-quit'.
  378.  
  379.  - Variable: inhibit-quit
  380.      This variable determines whether XEmacs should quit when
  381.      `quit-flag' is set to a value other than `nil'.  If `inhibit-quit'
  382.      is non-`nil', then `quit-flag' has no special effect.
  383.  
  384.  - Command: keyboard-quit
  385.      This function signals the `quit' condition with `(signal 'quit
  386.      nil)'.  This is the same thing that quitting does.  (See `signal'
  387.      in *Note Errors::.)
  388.  
  389.    You can specify a character other than `C-g' to use for quitting.
  390. See the function `set-input-mode' in *Note Terminal Input::.
  391.  
  392. 
  393. File: lispref.info,  Node: Prefix Command Arguments,  Next: Recursive Editing,  Prev: Quitting,  Up: Command Loop
  394.  
  395. Prefix Command Arguments
  396. ========================
  397.  
  398.    Most XEmacs commands can use a "prefix argument", a number specified
  399. before the command itself.  (Don't confuse prefix arguments with prefix
  400. keys.)  The prefix argument is at all times represented by a value,
  401. which may be `nil', meaning there is currently no prefix argument.
  402. Each command may use the prefix argument or ignore it.
  403.  
  404.    There are two representations of the prefix argument: "raw" and
  405. "numeric".  The editor command loop uses the raw representation
  406. internally, and so do the Lisp variables that store the information, but
  407. commands can request either representation.
  408.  
  409.    Here are the possible values of a raw prefix argument:
  410.  
  411.    * `nil', meaning there is no prefix argument.  Its numeric value is
  412.      1, but numerous commands make a distinction between `nil' and the
  413.      integer 1.
  414.  
  415.    * An integer, which stands for itself.
  416.  
  417.    * A list of one element, which is an integer.  This form of prefix
  418.      argument results from one or a succession of `C-u''s with no
  419.      digits.  The numeric value is the integer in the list, but some
  420.      commands make a distinction between such a list and an integer
  421.      alone.
  422.  
  423.    * The symbol `-'.  This indicates that `M--' or `C-u -' was typed,
  424.      without following digits.  The equivalent numeric value is -1, but
  425.      some commands make a distinction between the integer -1 and the
  426.      symbol `-'.
  427.  
  428.    We illustrate these possibilities by calling the following function
  429. with various prefixes:
  430.  
  431.      (defun display-prefix (arg)
  432.        "Display the value of the raw prefix arg."
  433.        (interactive "P")
  434.        (message "%s" arg))
  435.  
  436. Here are the results of calling `display-prefix' with various raw
  437. prefix arguments:
  438.  
  439.              M-x display-prefix  -| nil
  440.      
  441.      C-u     M-x display-prefix  -| (4)
  442.      
  443.      C-u C-u M-x display-prefix  -| (16)
  444.      
  445.      C-u 3   M-x display-prefix  -| 3
  446.      
  447.      M-3     M-x display-prefix  -| 3      ; (Same as `C-u 3'.)
  448.      
  449.      C-3     M-x display-prefix  -| 3      ; (Same as `C-u 3'.)
  450.      
  451.      C-u -   M-x display-prefix  -| -
  452.      
  453.      M--     M-x display-prefix  -| -      ; (Same as `C-u -'.)
  454.      
  455.      C--     M-x display-prefix  -| -      ; (Same as `C-u -'.)
  456.      
  457.      C-u - 7 M-x display-prefix  -| -7
  458.      
  459.      M-- 7   M-x display-prefix  -| -7     ; (Same as `C-u -7'.)
  460.      
  461.      C-- 7   M-x display-prefix  -| -7     ; (Same as `C-u -7'.)
  462.  
  463.    XEmacs uses two variables to store the prefix argument: `prefix-arg'
  464. and `current-prefix-arg'.  Commands such as `universal-argument' that
  465. set up prefix arguments for other commands store them in `prefix-arg'.
  466. In contrast, `current-prefix-arg' conveys the prefix argument to the
  467. current command, so setting it has no effect on the prefix arguments
  468. for future commands.
  469.  
  470.    Normally, commands specify which representation to use for the prefix
  471. argument, either numeric or raw, in the `interactive' declaration.
  472. (*Note Using Interactive::.)  Alternatively, functions may look at the
  473. value of the prefix argument directly in the variable
  474. `current-prefix-arg', but this is less clean.
  475.  
  476.  - Function: prefix-numeric-value ARG
  477.      This function returns the numeric meaning of a valid raw prefix
  478.      argument value, ARG.  The argument may be a symbol, a number, or a
  479.      list.  If it is `nil', the value 1 is returned; if it is `-', the
  480.      value -1 is returned; if it is a number, that number is returned;
  481.      if it is a list, the CAR of that list (which should be a number) is
  482.      returned.
  483.  
  484.  - Variable: current-prefix-arg
  485.      This variable holds the raw prefix argument for the *current*
  486.      command.  Commands may examine it directly, but the usual way to
  487.      access it is with `(interactive "P")'.
  488.  
  489.  - Variable: prefix-arg
  490.      The value of this variable is the raw prefix argument for the
  491.      *next* editing command.  Commands that specify prefix arguments for
  492.      the following command work by setting this variable.
  493.  
  494.    Do not call the functions `universal-argument', `digit-argument', or
  495. `negative-argument' unless you intend to let the user enter the prefix
  496. argument for the *next* command.
  497.  
  498.  - Command: universal-argument
  499.      This command reads input and specifies a prefix argument for the
  500.      following command.  Don't call this command yourself unless you
  501.      know what you are doing.
  502.  
  503.  - Command: digit-argument ARG
  504.      This command adds to the prefix argument for the following
  505.      command.  The argument ARG is the raw prefix argument as it was
  506.      before this command; it is used to compute the updated prefix
  507.      argument.  Don't call this command yourself unless you know what
  508.      you are doing.
  509.  
  510.  - Command: negative-argument ARG
  511.      This command adds to the numeric argument for the next command.
  512.      The argument ARG is the raw prefix argument as it was before this
  513.      command; its value is negated to form the new prefix argument.
  514.      Don't call this command yourself unless you know what you are
  515.      doing.
  516.  
  517. 
  518. File: lispref.info,  Node: Recursive Editing,  Next: Disabling Commands,  Prev: Prefix Command Arguments,  Up: Command Loop
  519.  
  520. Recursive Editing
  521. =================
  522.  
  523.    The XEmacs command loop is entered automatically when XEmacs starts
  524. up.  This top-level invocation of the command loop never exits; it keeps
  525. running as long as XEmacs does.  Lisp programs can also invoke the
  526. command loop.  Since this makes more than one activation of the command
  527. loop, we call it "recursive editing".  A recursive editing level has
  528. the effect of suspending whatever command invoked it and permitting the
  529. user to do arbitrary editing before resuming that command.
  530.  
  531.    The commands available during recursive editing are the same ones
  532. available in the top-level editing loop and defined in the keymaps.
  533. Only a few special commands exit the recursive editing level; the others
  534. return to the recursive editing level when they finish.  (The special
  535. commands for exiting are always available, but they do nothing when
  536. recursive editing is not in progress.)
  537.  
  538.    All command loops, including recursive ones, set up all-purpose error
  539. handlers so that an error in a command run from the command loop will
  540. not exit the loop.
  541.  
  542.    Minibuffer input is a special kind of recursive editing.  It has a
  543. few special wrinkles, such as enabling display of the minibuffer and the
  544. minibuffer window, but fewer than you might suppose.  Certain keys
  545. behave differently in the minibuffer, but that is only because of the
  546. minibuffer's local map; if you switch windows, you get the usual XEmacs
  547. commands.
  548.  
  549.    To invoke a recursive editing level, call the function
  550. `recursive-edit'.  This function contains the command loop; it also
  551. contains a call to `catch' with tag `exit', which makes it possible to
  552. exit the recursive editing level by throwing to `exit' (*note Catch and
  553. Throw::.).  If you throw a value other than `t', then `recursive-edit'
  554. returns normally to the function that called it.  The command `C-M-c'
  555. (`exit-recursive-edit') does this.  Throwing a `t' value causes
  556. `recursive-edit' to quit, so that control returns to the command loop
  557. one level up.  This is called "aborting", and is done by `C-]'
  558. (`abort-recursive-edit').
  559.  
  560.    Most applications should not use recursive editing, except as part of
  561. using the minibuffer.  Usually it is more convenient for the user if you
  562. change the major mode of the current buffer temporarily to a special
  563. major mode, which should have a command to go back to the previous mode.
  564. (The `e' command in Rmail uses this technique.)  Or, if you wish to
  565. give the user different text to edit "recursively", create and select a
  566. new buffer in a special mode.  In this mode, define a command to
  567. complete the processing and go back to the previous buffer.  (The `m'
  568. command in Rmail does this.)
  569.  
  570.    Recursive edits are useful in debugging.  You can insert a call to
  571. `debug' into a function definition as a sort of breakpoint, so that you
  572. can look around when the function gets there.  `debug' invokes a
  573. recursive edit but also provides the other features of the debugger.
  574.  
  575.    Recursive editing levels are also used when you type `C-r' in
  576. `query-replace' or use `C-x q' (`kbd-macro-query').
  577.  
  578.  - Function: recursive-edit
  579.      This function invokes the editor command loop.  It is called
  580.      automatically by the initialization of XEmacs, to let the user
  581.      begin editing.  When called from a Lisp program, it enters a
  582.      recursive editing level.
  583.  
  584.      In the following example, the function `simple-rec' first advances
  585.      point one word, then enters a recursive edit, printing out a
  586.      message in the echo area.  The user can then do any editing
  587.      desired, and then type `C-M-c' to exit and continue executing
  588.      `simple-rec'.
  589.  
  590.           (defun simple-rec ()
  591.             (forward-word 1)
  592.             (message "Recursive edit in progress")
  593.             (recursive-edit)
  594.             (forward-word 1))
  595.                => simple-rec
  596.           (simple-rec)
  597.                => nil
  598.  
  599.  - Command: exit-recursive-edit
  600.      This function exits from the innermost recursive edit (including
  601.      minibuffer input).  Its definition is effectively `(throw 'exit
  602.      nil)'.
  603.  
  604.  - Command: abort-recursive-edit
  605.      This function aborts the command that requested the innermost
  606.      recursive edit (including minibuffer input), by signaling `quit'
  607.      after exiting the recursive edit.  Its definition is effectively
  608.      `(throw 'exit t)'.  *Note Quitting::.
  609.  
  610.  - Command: top-level
  611.      This function exits all recursive editing levels; it does not
  612.      return a value, as it jumps completely out of any computation
  613.      directly back to the main command loop.
  614.  
  615.  - Function: recursion-depth
  616.      This function returns the current depth of recursive edits.  When
  617.      no recursive edit is active, it returns 0.
  618.  
  619. 
  620. File: lispref.info,  Node: Disabling Commands,  Next: Command History,  Prev: Recursive Editing,  Up: Command Loop
  621.  
  622. Disabling Commands
  623. ==================
  624.  
  625.    "Disabling a command" marks the command as requiring user
  626. confirmation before it can be executed.  Disabling is used for commands
  627. which might be confusing to beginning users, to prevent them from using
  628. the commands by accident.
  629.  
  630.    The low-level mechanism for disabling a command is to put a
  631. non-`nil' `disabled' property on the Lisp symbol for the command.
  632. These properties are normally set up by the user's `.emacs' file with
  633. Lisp expressions such as this:
  634.  
  635.      (put 'upcase-region 'disabled t)
  636.  
  637. For a few commands, these properties are present by default and may be
  638. removed by the `.emacs' file.
  639.  
  640.    If the value of the `disabled' property is a string, the message
  641. saying the command is disabled includes that string.  For example:
  642.  
  643.      (put 'delete-region 'disabled
  644.           "Text deleted this way cannot be yanked back!\n")
  645.  
  646.    *Note Disabling: (emacs)Disabling, for the details on what happens
  647. when a disabled command is invoked interactively.  Disabling a command
  648. has no effect on calling it as a function from Lisp programs.
  649.  
  650.  - Command: enable-command COMMAND
  651.      Allow COMMAND to be executed without special confirmation from now
  652.      on, and (if the user confirms) alter the user's `.emacs' file so
  653.      that this will apply to future sessions.
  654.  
  655.  - Command: disable-command COMMAND
  656.      Require special confirmation to execute COMMAND from now on, and
  657.      (if the user confirms) alter the user's `.emacs' file so that this
  658.      will apply to future sessions.
  659.  
  660.  - Variable: disabled-command-hook
  661.      This normal hook is run instead of a disabled command, when the
  662.      user invokes the disabled command interactively.  The hook
  663.      functions can use `this-command-keys' to determine what the user
  664.      typed to run the command, and thus find the command itself.  *Note
  665.      Hooks::.
  666.  
  667.      By default, `disabled-command-hook' contains a function that asks
  668.      the user whether to proceed.
  669.  
  670. 
  671. File: lispref.info,  Node: Command History,  Next: Keyboard Macros,  Prev: Disabling Commands,  Up: Command Loop
  672.  
  673. Command History
  674. ===============
  675.  
  676.    The command loop keeps a history of the complex commands that have
  677. been executed, to make it convenient to repeat these commands.  A
  678. "complex command" is one for which the interactive argument reading
  679. uses the minibuffer.  This includes any `M-x' command, any `M-:'
  680. command, and any command whose `interactive' specification reads an
  681. argument from the minibuffer.  Explicit use of the minibuffer during
  682. the execution of the command itself does not cause the command to be
  683. considered complex.
  684.  
  685.  - Variable: command-history
  686.      This variable's value is a list of recent complex commands, each
  687.      represented as a form to evaluate.  It continues to accumulate all
  688.      complex commands for the duration of the editing session, but all
  689.      but the first (most recent) thirty elements are deleted when a
  690.      garbage collection takes place (*note Garbage Collection::.).
  691.  
  692.           command-history
  693.           => ((switch-to-buffer "chistory.texi")
  694.               (describe-key "^X^[")
  695.               (visit-tags-table "~/emacs/src/")
  696.               (find-tag "repeat-complex-command"))
  697.  
  698.    This history list is actually a special case of minibuffer history
  699. (*note Minibuffer History::.), with one special twist: the elements are
  700. expressions rather than strings.
  701.  
  702.    There are a number of commands devoted to the editing and recall of
  703. previous commands.  The commands `repeat-complex-command', and
  704. `list-command-history' are described in the user manual (*note
  705. Repetition: (emacs)Repetition.).  Within the minibuffer, the history
  706. commands used are the same ones available in any minibuffer.
  707.  
  708. 
  709. File: lispref.info,  Node: Keyboard Macros,  Prev: Command History,  Up: Command Loop
  710.  
  711. Keyboard Macros
  712. ===============
  713.  
  714.    A "keyboard macro" is a canned sequence of input events that can be
  715. considered a command and made the definition of a key.  The Lisp
  716. representation of a keyboard macro is a string or vector containing the
  717. events.  Don't confuse keyboard macros with Lisp macros (*note
  718. Macros::.).
  719.  
  720.  - Function: execute-kbd-macro MACRO &optional COUNT
  721.      This function executes MACRO as a sequence of events.  If MACRO is
  722.      a string or vector, then the events in it are executed exactly as
  723.      if they had been input by the user.  The sequence is *not*
  724.      expected to be a single key sequence; normally a keyboard macro
  725.      definition consists of several key sequences concatenated.
  726.  
  727.      If MACRO is a symbol, then its function definition is used in
  728.      place of MACRO.  If that is another symbol, this process repeats.
  729.      Eventually the result should be a string or vector.  If the result
  730.      is not a symbol, string, or vector, an error is signaled.
  731.  
  732.      The argument COUNT is a repeat count; MACRO is executed that many
  733.      times.  If COUNT is omitted or `nil', MACRO is executed once.  If
  734.      it is 0, MACRO is executed over and over until it encounters an
  735.      error or a failing search.
  736.  
  737.  - Variable: executing-macro
  738.      This variable contains the string or vector that defines the
  739.      keyboard macro that is currently executing.  It is `nil' if no
  740.      macro is currently executing.  A command can test this variable to
  741.      behave differently when run from an executing macro.  Do not set
  742.      this variable yourself.
  743.  
  744.  - Variable: defining-kbd-macro
  745.      This variable indicates whether a keyboard macro is being defined.
  746.      A command can test this variable to behave differently while a
  747.      macro is being defined.  The commands `start-kbd-macro' and
  748.      `end-kbd-macro' set this variable--do not set it yourself.
  749.  
  750.  - Variable: last-kbd-macro
  751.      This variable is the definition of the most recently defined
  752.      keyboard macro.  Its value is a string or vector, or `nil'.
  753.  
  754.    The commands are described in the user's manual (*note Keyboard
  755. Macros: (xemacs)Keyboard Macros.).
  756.  
  757. 
  758. File: lispref.info,  Node: Keymaps,  Next: Menus,  Prev: Command Loop,  Up: Top
  759.  
  760. Keymaps
  761. *******
  762.  
  763.    The bindings between input events and commands are recorded in data
  764. structures called "keymaps".  Each binding in a keymap associates (or
  765. "binds") an individual event type either with another keymap or with a
  766. command.  When an event is bound to a keymap, that keymap is used to
  767. look up the next input event; this continues until a command is found.
  768. The whole process is called "key lookup".
  769.  
  770. * Menu:
  771.  
  772. * Keymap Terminology::       Definitions of terms pertaining to keymaps.
  773. * Format of Keymaps::        What a keymap looks like as a Lisp object.
  774. * Creating Keymaps::         Functions to create and copy keymaps.
  775. * Inheritance and Keymaps::  How one keymap can inherit the bindings
  776.                                 of another keymap.
  777. * Key Sequences::            How to specify key sequences.
  778. * Prefix Keys::              Defining a key with a keymap as its definition.
  779. * Active Keymaps::           Each buffer has a local keymap
  780.                                 to override the standard (global) bindings.
  781.                                 A minor mode can also override them.
  782. * Key Lookup::               How extracting elements from keymaps works.
  783. * Functions for Key Lookup:: How to request key lookup.
  784. * Changing Key Bindings::    Redefining a key in a keymap.
  785. * Key Binding Commands::     Interactive interfaces for redefining keys.
  786. * Scanning Keymaps::         Looking through all keymaps, for printing help.
  787. * Other Keymap Functions::   Miscellaneous keymap functions.
  788.  
  789. 
  790. File: lispref.info,  Node: Keymap Terminology,  Next: Format of Keymaps,  Up: Keymaps
  791.  
  792. Keymap Terminology
  793. ==================
  794.  
  795.    A "keymap" is a table mapping event types to definitions (which can
  796. be any Lisp objects, though only certain types are meaningful for
  797. execution by the command loop).  Given an event (or an event type) and a
  798. keymap, XEmacs can get the event's definition.  Events mapped in keymaps
  799. include keypresses, button presses, and button releases (*note
  800. Events::.).
  801.  
  802.    A sequence of input events that form a unit is called a "key
  803. sequence", or "key" for short.  A sequence of one event is always a key
  804. sequence, and so are some multi-event sequences.
  805.  
  806.    A keymap determines a binding or definition for any key sequence.  If
  807. the key sequence is a single event, its binding is the definition of the
  808. event in the keymap.  The binding of a key sequence of more than one
  809. event is found by an iterative process: the binding of the first event
  810. is found, and must be a keymap; then the second event's binding is found
  811. in that keymap, and so on until all the events in the key sequence are
  812. used up.
  813.  
  814.    If the binding of a key sequence is a keymap, we call the key
  815. sequence a "prefix key".  Otherwise, we call it a "complete key"
  816. (because no more events can be added to it).  If the binding is `nil',
  817. we call the key "undefined".  Examples of prefix keys are `C-c', `C-x',
  818. and `C-x 4'.  Examples of defined complete keys are `X', <RET>, and
  819. `C-x 4 C-f'.  Examples of undefined complete keys are `C-x C-g', and
  820. `C-c 3'.  *Note Prefix Keys::, for more details.
  821.  
  822.    The rule for finding the binding of a key sequence assumes that the
  823. intermediate bindings (found for the events before the last) are all
  824. keymaps; if this is not so, the sequence of events does not form a
  825. unit--it is not really a key sequence.  In other words, removing one or
  826. more events from the end of any valid key must always yield a prefix
  827. key.  For example, `C-f C-n' is not a key; `C-f' is not a prefix key,
  828. so a longer sequence starting with `C-f' cannot be a key.
  829.  
  830.    Note that the set of possible multi-event key sequences depends on
  831. the bindings for prefix keys; therefore, it can be different for
  832. different keymaps, and can change when bindings are changed.  However,
  833. a one-event sequence is always a key sequence, because it does not
  834. depend on any prefix keys for its well-formedness.
  835.  
  836.    At any time, several primary keymaps are "active"--that is, in use
  837. for finding key bindings.  These are the "global map", which is shared
  838. by all buffers; the "local keymap", which is usually associated with a
  839. specific major mode; and zero or more "minor mode keymaps", which
  840. belong to currently enabled minor modes.  (Not all minor modes have
  841. keymaps.)  The local keymap bindings shadow (i.e., take precedence
  842. over) the corresponding global bindings.  The minor mode keymaps shadow
  843. both local and global keymaps.  *Note Active Keymaps::, for details.
  844.  
  845. 
  846. File: lispref.info,  Node: Format of Keymaps,  Next: Creating Keymaps,  Prev: Keymap Terminology,  Up: Keymaps
  847.  
  848. Format of Keymaps
  849. =================
  850.  
  851.    A keymap is a primitive type that associates events with their
  852. bindings.  Note that this is different from Emacs 18 and FSF Emacs,
  853. where keymaps are lists.
  854.  
  855.  - Function: keymapp OBJECT
  856.      This function returns `t' if OBJECT is a keymap, `nil' otherwise.
  857.  
  858. 
  859. File: lispref.info,  Node: Creating Keymaps,  Next: Inheritance and Keymaps,  Prev: Format of Keymaps,  Up: Keymaps
  860.  
  861. Creating Keymaps
  862. ================
  863.  
  864.    Here we describe the functions for creating keymaps.
  865.  
  866.  - Function: make-keymap &optional NAME
  867.      This function constructs and returns a new keymap object.  All
  868.      entries in it are `nil', meaning "command undefined".
  869.  
  870.      Optional argument NAME specifies a name to assign to the keymap,
  871.      as in `set-keymap-name'.  This name is only a debugging
  872.      convenience; it is not used except when printing the keymap.
  873.  
  874.  - Function: make-sparse-keymap &optional NAME
  875.      This function constructs and returns a new keymap object.  All
  876.      entries in it are `nil', meaning "command undefined".  The only
  877.      difference between this function and `make-keymap' is that this
  878.      function returns a "smaller" keymap (one that is expected to
  879.      contain fewer entries).  As keymaps dynamically resize, the
  880.      distinction is not great.
  881.  
  882.      Optional argument NAME specifies a name to assign to the keymap,
  883.      as in `set-keymap-name'.  This name is only a debugging
  884.      convenience; it is not used except when printing the keymap.
  885.  
  886.  - Function: set-keymap-name KEYMAP NEW-NAME
  887.      This function assigns a "name" to a keymap.  The name is only a
  888.      debugging convenience; it is not used except when printing the
  889.      keymap.
  890.  
  891.  - Function: keymap-name KEYMAP
  892.      This function returns the "name" of a keymap, as assigned using
  893.      `set-keymap-name'.
  894.  
  895.  - Function: copy-keymap KEYMAP
  896.      This function returns a copy of KEYMAP.  Any keymaps that appear
  897.      directly as bindings in KEYMAP are also copied recursively, and so
  898.      on to any number of levels.  However, recursive copying does not
  899.      take place when the definition of a character is a symbol whose
  900.      function definition is a keymap; the same symbol appears in the
  901.      new copy.
  902.  
  903.           (setq map (copy-keymap (current-local-map)))
  904.           => #<keymap 3 entries 0x21f80>
  905.           
  906.           (eq map (current-local-map))
  907.               => nil
  908.  
  909. 
  910. File: lispref.info,  Node: Inheritance and Keymaps,  Next: Key Sequences,  Prev: Creating Keymaps,  Up: Keymaps
  911.  
  912. Inheritance and Keymaps
  913. =======================
  914.  
  915.    A keymap can inherit the bindings of other keymaps.  The other
  916. keymaps are called the keymap's "parents", and are set with
  917. `set-keymap-parents'.  When searching for a binding for a key sequence
  918. in a particular keymap, that keymap itself will first be searched;
  919. then, if no binding was found in the map and it has parents, the first
  920. parent keymap will be searched; then that keymap's parent will be
  921. searched, and so on, until either a binding for the key sequence is
  922. found, or a keymap without a parent is encountered.  At this point, the
  923. search will continue with the next parent of the most recently
  924. encountered keymap that has another parent, etc.  Essentially, a
  925. depth-first search of all the ancestors of the keymap is conducted.
  926.  
  927.    `(current-global-map)' is the default parent of all keymaps.
  928.  
  929.  - Function: set-keymap-parents KEYMAP PARENTS
  930.      This function sets the parent keymaps of KEYMAP to the list
  931.      PARENTS.
  932.  
  933.      If you change the bindings in one of the keymaps in PARENTS using
  934.      `define-key' or other key-binding functions, these changes are
  935.      visible in KEYMAP unless shadowed by bindings in that map or in
  936.      earlier-searched ancestors.  The converse is not true: if you use
  937.      `define-key' to change KEYMAP, that affects the bindings in that
  938.      map, but has no effect on any of the keymaps in PARENTS.
  939.  
  940.  - Function: keymap-parents KEYMAP
  941.      This function returns the list of parent keymaps of KEYMAP, or
  942.      `nil' if KEYMAP has no parents.
  943.  
  944.    As an alternative to specifying a parent, you can also specify a
  945. "default binding" that is used whenever a key is not otherwise bound in
  946. the keymap.  This is useful for terminal emulators, for example, which
  947. may want to trap all keystrokes and pass them on in some modified
  948. format.  Note that if you specify a default binding for a keymap,
  949. neither the keymap's parents nor the current global map are searched for
  950. key bindings.
  951.  
  952.  - Function: set-keymap-default-binding KEYMAP COMMAND
  953.      This function sets the default binding of KEYMAP to COMMAND, or
  954.      `nil' if no default is desired.
  955.  
  956.  - Function: keymap-default-binding KEYMAP
  957.      This function returns the default binding of KEYMAP, or `nil' if
  958.      it has none.
  959.  
  960. 
  961. File: lispref.info,  Node: Key Sequences,  Next: Prefix Keys,  Prev: Inheritance and Keymaps,  Up: Keymaps
  962.  
  963. Key Sequences
  964. =============
  965.  
  966.    Contrary to popular belief, the world is not ASCII.  When running
  967. under a window manager, XEmacs can tell the difference between, for
  968. example, the keystrokes `control-h', `control-shift-h', and
  969. `backspace'.  You can, in fact, bind different commands to each of
  970. these.
  971.  
  972.    A "key sequence" is a set of keystrokes.  A "keystroke" is a keysym
  973. and some set of modifiers (such as <CONTROL> and <META>).  A "keysym"
  974. is what is printed on the keys on your keyboard.
  975.  
  976.    A keysym may be represented by a symbol, or (if and only if it is
  977. equivalent to an ASCII character in the range 32 - 255) by a character
  978. or its equivalent ASCII code.  The `A' key may be represented by the
  979. symbol `A', the character `?A', or by the number 65.  The `break' key
  980. may be represented only by the symbol `break'.
  981.  
  982.    A keystroke may be represented by a list: the last element of the
  983. list is the key (a symbol, character, or number, as above) and the
  984. preceding elements are the symbolic names of modifier keys (<CONTROL>,
  985. <META>, <SUPER>, <HYPER>, <ALT>, and <SHIFT>).  Thus, the sequence
  986. `control-b' is represented by the forms `(control b)', `(control ?b)',
  987. and `(control 98)'.  A keystroke may also be represented by an event
  988. object, as returned by the `next-command-event' and `read-key-sequence'
  989. functions.
  990.  
  991.    Note that in this context, the keystroke `control-b' is *not*
  992. represented by the number 2 (the ASCII code for `^B') or the character
  993. `?\^B'.  See below.
  994.  
  995.    The <SHIFT> modifier is somewhat of a special case.  You should not
  996. (and cannot) use `(meta shift a)' to mean `(meta A)', since for
  997. characters that have ASCII equivalents, the state of the shift key is
  998. implicit in the keysym (`a' vs. `A').  You also cannot say `(shift =)'
  999. to mean `+', as that sort of thing varies from keyboard to keyboard.
  1000. The <SHIFT> modifier is for use only with characters that do not have a
  1001. second keysym on the same key, such as `backspace' and `tab'.
  1002.  
  1003.    A key sequence is a vector of keystrokes.  As a degenerate case,
  1004. elements of this vector may also be keysyms if they have no modifiers.
  1005. That is, the `A' keystroke is represented by all of these forms:
  1006.  
  1007.          A    ?A    65    (A)    (?A)    (65)
  1008.          [A]    [?A]    [65]    [(A)]    [(?A)]    [(65)]
  1009.  
  1010.    the `control-a' keystroke is represented by these forms:
  1011.  
  1012.          (control A)    (control ?A)    (control 65)
  1013.          [(control A)]    [(control ?A)]    [(control 65)]
  1014.  
  1015.    the key sequence `control-c control-a' is represented by these forms:
  1016.  
  1017.          [(control c) (control a)]    [(control ?c) (control ?a)]
  1018.          [(control 99) (control 65)]    etc.
  1019.  
  1020.    Mouse button clicks work just like keypresses: `(control button1)'
  1021. means pressing the left mouse button while holding down the control
  1022. key.  `[(control c) (shift button3)]' means `control-c', hold <SHIFT>,
  1023. click right.
  1024.  
  1025.    Commands may be bound to the mouse-button up-stroke rather than the
  1026. down-stroke as well.  `button1' means the down-stroke, and `button1up'
  1027. means the up-stroke.  Different commands may be bound to the up and
  1028. down strokes, though that is probably not what you want, so be careful.
  1029.  
  1030.    For backward compatibility, a key sequence may also be represented by
  1031. a string.  In this case, it represents the key sequence(s) that would
  1032. produce that sequence of ASCII characters in a purely ASCII world.  For
  1033. example, a string containing the ASCII backspace character, `"\^H"',
  1034. would represent two key sequences: `(control h)' and `backspace'.
  1035. Binding a command to this will actually bind both of those key
  1036. sequences.  Likewise for the following pairs:
  1037.  
  1038.              control h    backspace
  1039.              control i       tab
  1040.              control m       return
  1041.              control j       linefeed
  1042.              control [       escape
  1043.              control @    control space
  1044.  
  1045.    After binding a command to two key sequences with a form like
  1046.  
  1047.          (define-key global-map "\^X\^I" 'command-1)
  1048.  
  1049. it is possible to redefine only one of those sequences like so:
  1050.  
  1051.          (define-key global-map [(control x) (control i)] 'command-2)
  1052.          (define-key global-map [(control x) tab] 'command-3)
  1053.  
  1054.    Of course, all of this applies only when running under a window
  1055. system.  If you're talking to XEmacs through a TTY connection, you
  1056. don't get any of these features.
  1057.  
  1058.  - Function: event-matches-key-specifier-p EVENT KEY-SPECIFIER
  1059.      This function returns non-`nil' if EVENT matches KEY-SPECIFIER,
  1060.      which can be any valid form representing a key sequence.  This can
  1061.      be useful, e.g., to determine if the user pressed `help-char' or
  1062.      `quit-char'.
  1063.  
  1064. 
  1065. File: lispref.info,  Node: Prefix Keys,  Next: Active Keymaps,  Prev: Key Sequences,  Up: Keymaps
  1066.  
  1067. Prefix Keys
  1068. ===========
  1069.  
  1070.    A "prefix key" has an associated keymap that defines what to do with
  1071. key sequences that start with the prefix key.  For example, `C-x' is a
  1072. prefix key, and it uses a keymap that is also stored in the variable
  1073. `ctl-x-map'.  Here is a list of the standard prefix keys of XEmacs and
  1074. their keymaps:
  1075.  
  1076.    * `help-map' is used for events that follow `C-h'.
  1077.  
  1078.    * `mode-specific-map' is for events that follow `C-c'.  This map is
  1079.      not actually mode specific; its name was chosen to be informative
  1080.      for the user in `C-h b' (`display-bindings'), where it describes
  1081.      the main use of the `C-c' prefix key.
  1082.  
  1083.    * `ctl-x-map' is the map used for events that follow `C-x'.  This
  1084.      map is also the function definition of `Control-X-prefix'.
  1085.  
  1086.    * `ctl-x-4-map' is used for events that follow `C-x 4'.
  1087.  
  1088.    * `ctl-x-5-map' is used for events that follow `C-x 5'.
  1089.  
  1090.    * The prefix keys `C-x n', `C-x r' and `C-x a' use keymaps that have
  1091.      no special name.
  1092.  
  1093.    * `esc-map' is an evil hack that is present for compatibility
  1094.      purposes with Emacs 18.  Defining a key in `esc-map' is equivalent
  1095.      to defining the same key in `global-map' but with the <META>
  1096.      prefix added.  You should *not* use this in your code. (This map is
  1097.      also the function definition of `ESC-prefix'.)
  1098.  
  1099.    The binding of a prefix key is the keymap to use for looking up the
  1100. events that follow the prefix key.  (It may instead be a symbol whose
  1101. function definition is a keymap.  The effect is the same, but the symbol
  1102. serves as a name for the prefix key.)  Thus, the binding of `C-x' is
  1103. the symbol `Control-X-prefix', whose function definition is the keymap
  1104. for `C-x' commands.  (The same keymap is also the value of `ctl-x-map'.)
  1105.  
  1106.    Prefix key definitions can appear in any active keymap.  The
  1107. definitions of `C-c', `C-x', `C-h' and <ESC> as prefix keys appear in
  1108. the global map, so these prefix keys are always available.  Major and
  1109. minor modes can redefine a key as a prefix by putting a prefix key
  1110. definition for it in the local map or the minor mode's map.  *Note
  1111. Active Keymaps::.
  1112.  
  1113.    If a key is defined as a prefix in more than one active map, then its
  1114. various definitions are in effect merged: the commands defined in the
  1115. minor mode keymaps come first, followed by those in the local map's
  1116. prefix definition, and then by those from the global map.
  1117.  
  1118.    In the following example, we make `C-p' a prefix key in the local
  1119. keymap, in such a way that `C-p' is identical to `C-x'.  Then the
  1120. binding for `C-p C-f' is the function `find-file', just like `C-x C-f'.
  1121. The key sequence `C-p 6' is not found in any active keymap.
  1122.  
  1123.      (use-local-map (make-sparse-keymap))
  1124.          => nil
  1125.      (local-set-key "\C-p" ctl-x-map)
  1126.          => nil
  1127.      (key-binding "\C-p\C-f")
  1128.          => find-file
  1129.      
  1130.      (key-binding "\C-p6")
  1131.          => nil
  1132.  
  1133.  - Function: define-prefix-command SYMBOL &optional MAPVAR
  1134.      This function defines SYMBOL as a prefix command: it creates a
  1135.      keymap and stores it as SYMBOL's function definition.  Storing the
  1136.      symbol as the binding of a key makes the key a prefix key that has
  1137.      a name.  If optional argument MAPVAR is not specified, it also
  1138.      sets SYMBOL as a variable, to have the keymap as its value. (If
  1139.      MAPVAR is given and is not `t', its value is stored as the value
  1140.      of SYMBOL.) The function returns SYMBOL.
  1141.  
  1142.      In Emacs version 18, only the function definition of SYMBOL was
  1143.      set, not the value as a variable.
  1144.  
  1145.